from google.appengine.ext import webapp
from google.appengine.ext import db

class DownloadModule(webapp.RequestHandler):
    def get(self):
        current_order_number = self.request.get("order_number","")

        if current_order_number <> "" : 
            post_datas = db.GqlQuery("select * from OrderData where order_number = :1",
                                    current_order_number)
            if post_datas.count() > 0:
                post_data = post_datas[0]
                fileName = post_data.attched_file_name
                fileData = post_data.attched_file
        
        self.response.headers['Content-disposition'] = 'attachment;filename=' + fileName
        self.response.out.write(fileData)